<%@include file="/WEB-INF/templates/configuration.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="windows-1252"%>
<%
HttpSession session_user = request.getSession(true);
    String firstname = (String) session_user.getAttribute("user_firstname");
    int user_id = 0;
    int user_type=0;
    if(firstname!=null){
        user_id = Integer.valueOf("" + session_user.getAttribute("user_id"));
        user_type = Integer.valueOf("" + session_user.getAttribute("user_type"));
    }

%>
<% if(user_type == 2|| user_type == 3){
    %>
    <c:if test="${not empty foutMelding}">
    <!-- Mochten er foutmeldingen zijn, dan worden ze hier getoond -->
    <p>${foutMelding}</p>
</c:if>
<c:choose>
    <c:when test="${empty newsid}">
        <!-- Als er geen id is meegegeven, ga je een gebruiker toevoegen -->
            <form id="nieuwNieuws" action="new" method="post">
        </c:when>
        <c:otherwise>
            <!-- Anders ga je een gebruiker wijzigen -->
            <form id="wijzigenNieuws" action="edit" method="post">
            </c:otherwise>
        </c:choose>
        <p>
            <c:if test="${not empty newsid}">
                <!-- Het id wordt meegestuurd, om te bepalen welke gebruiker je gaat wijzigen -->
                <input type="hidden" name="newsid" id="newsid" value="${newsid}" />
            </c:if>
        </p>
        <table border="0">
            <tr>
                <td><label for="newstitle">News Title</label></td>
                <td><input type="text" id="newstitle" name="newstitle" value="${news.newstitle}" /></td>
            </tr>
            <tr>
                <td><label for="newscontent">News Content</label></td>
                <td><textarea id="newscontent" name="newscontent" rows="8" cols="50" class="mceEditor">${news.newscontent}</textarea></td>
            </tr>
            <tr>
                <td> <label for="newsglobal">Type of news:</label></td>
                <td>
                    <select name="newsglobal" id="newsglobal">
                        <option value="0">Global</option>
                        <c:forEach var="tempCourse" items="${courses}">
                            <option value="${tempCourse.courseid}" <c:if test="${news.course.getCourseid() == tempCourse.courseid}">selected="selected"</c:if>>${tempCourse.coursetitle} </option>
                        </c:forEach>
                    </select>
                </td>
            </tr>
        </table>
        
        <p>
            <input class="submit" type="submit" value="Add">
        </p>
    </form>
            <%
}else{
%>
<p>Geen toegang!</p>
<%
}%>